package com.septimus.portal.service;

import org.apache.log4j.Logger;

import javax.ejb.Stateless;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.persistence.EntityManager;

import com.septimus.portal.model.Module;

@Stateless
public class ModuleRegistration {

	@Inject
	private Logger log;

	@Inject
	private EntityManager em;

	@Inject
	private Event<Module> moduleEventSrc;

	public Module register(Module module) throws Exception {
		log.info("\n\nRegistering " + module.getName());
		Module m = em.merge(module);
		moduleEventSrc.fire(module);
		return m;
	}

}
